import {pget, ppostJson} from '@/utils/req'
import {modalApi} from '@/utils/modalReq'

// 获取部门列表
export function getDeptList(query: any) {
	return pget(`${modalApi.system}/department/list`, query)
}

// 新增部门
export function addDept(val: any, currentMerchantId: any) {
	return ppostJson(`${modalApi.system}/department/create`, val, {
		headers: {
			currentMerchantId,
			Accept: 'application/json',
			'Content-Type': 'application/json',
		},
	})
}

// 修改部门
export function editDept(
	departmentId: string,
	val: any,
	currentMerchantId: any,
) {
	return ppostJson(
		`${modalApi.system}/department/update/${departmentId}`,
		val,
		{
			headers: {
				currentMerchantId,
				Accept: 'application/json',
				'Content-Type': 'application/json',
			},
		},
	)
}

// 删除部门
export function deleteDept(departmentId: string, currentMerchantId: any) {
	return ppostJson(
		`${modalApi.system}/department/delete/${departmentId}`,
		{},
		{
			headers: {
				currentMerchantId,
				Accept: 'application/json',
				'Content-Type': 'application/json',
			},
		},
	)
}

// 查看部门
export function viewDept(departmentId: string) {
	return pget(`${modalApi.system}/department/info/${departmentId}`)
}
